﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using System.Data;
using System.Reflection;
using System.Runtime.Serialization;
using System.Data.Objects;

namespace GTServices.Entities
{
    public class Category : BaseEntity
    { 
        [Key]
        public Guid Id { get; set; }
        public int Severity { get; set; }
        public String Name { get; set; }
         
        public bool Moderated { get; set; }
        public bool IsPublic { get; set; }

        public string ExploitScenario { get; set; } 
        public string Description { get; set; }       
        public string Recommendation { get; set; }
        public string References { get; set; } 

        public virtual Template       Template       { get; set; }
        public virtual Classification Classification { get; set; } 


        public virtual ObservableCollection<Pattern>  Patterns  { get; set; }
        //public virtual ObservableCollection<Language> Languages { get; set; } 

        public Category()
        {
            this.Id = Guid.NewGuid(); 
            this.Description = "";
           
            this.Name = "Default Name";
            this.Patterns = new ObservableCollection<Pattern>();
            //this.Languages = new ObservableCollection<Language>();
            this.Recommendation = "";
            this.References = ""; 
        }

        public override void Validate()
        {
           
            if (Description == null)
            {
                throw new ArgumentException("Description is Null");
            }
           
            if (Patterns == null)
            {
                throw new ArgumentException("Patterns is Null");
            }
        }

        public override bool Equals(object obj)
        {
            if (!(obj is Category))
            {
                return false;
            }
            return (obj as Category).Id == this.Id;
        }
    }
}
